pub fn convert_base(num_str: &str, to_base: u32) -> String {

    let parts: Vec<&str> = num_str.split('(').collect();
    let number_str = parts[0];
    let original_base: u32 = parts[1].trim_end_matches(')').parse().expect("Invalid base format");

    let decimal_value = u32::from_str_radix(number_str, original_base).expect("Invalid number format");

    format_radix(decimal_value, to_base)
}

fn format_radix(mut number: u32, radix: u32) -> String {
    let mut result = String::new();
    if number == 0 {
        return "0".to_string();
    }

    while number > 0 {
        let digit = match number % radix {
            n @ 0..=9 => (b'0' + n as u8) as char,
            n => (b'a' + (n - 10) as u8) as char,
        };
        result.insert(0, digit);
        number /= radix;
    }
    result
}